<?php /* @var $this Controller */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />

	<!-- blueprint CSS framework -->
	<!--<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/screen.css" media="screen, projection" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/print.css" media="print" />
	-->
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/ie.css" media="screen, projection" />
	<![endif]-->

	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/main.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/form.css" />

	<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>

<body>
<?php 
//echo Yii::app()->language;die();
$multiLangs = Yii::app()->params['languages'];
$languageArray['label'] = $multiLangs[Yii::app()->language];
$languageArray['url'] 	= "#";
$languageArray['items'] = "#";
$languageArray['linkOptions'] = array('class'=>Yii::app()->language);
$i=0;
foreach($multiLangs as $key => $item){
	if($key!=Yii::app()->language){
		$langsOther[$i]['label']= $multiLangs[$key];
		$langsOther[$i]['url']	= "javascript:void(0);";
		$langsOther[$i]['linkOptions']	= array('onclick'=>'$(\'#lang\').attr(\'value\',\''.$key.'\');document.langbox.submit();', 'class'=>$key);
		$i++;
	}
}
$languageArray['items'] = $langsOther;
if(!Yii::app()->user->isGuest){
	$user = User::model()->findByPk(Yii::app()->user->id);
	if(!empty($user->avatar)){
		$avatar = Yii::app()->params['storage_url'].'/profile/'.Yii::app()->user->id.'/thumb/'.$user->avatar;
	}else{
		$avatar = Yii::app()->theme->baseUrl.'/images/avatar.jpg';
	}
	$isSupperAdmin = ($user->superuser)?'<li><a href="'.Yii::app()->createUrl('/srbac/authitem/manage').'"><i class="icon-lock icon-blue"></i>'.Yii::t('main','SRBAC').'</a></li>':'';
}else{
	$avatar = Yii::app()->theme->baseUrl.'/images/avatar.jpg';
	$isSupperAdmin = false;
}

$contentMenu = array('label'=>'Content Manager', 'url'=>Yii::app()->createUrl('/news/news/admin'), 'icon'=>'list-alt blue', 'items'=>array(
		array('label'=>'Create New Article', 'url'=>Yii::app()->createUrl('/news/news/create'), 'icon'=>'plus blue', "visible"=>Yii::app()->user->checkAccess("News@NewsCreate", Yii::app()->user->Id)),
		array('label'=>'Article Manager', 'url'=>Yii::app()->createUrl('/news/news/admin'), 'icon'=>'list-alt blue', "visible"=>Yii::app()->user->checkAccess("News@NewsAdmin", Yii::app()->user->Id)),
		'---',
		array('label'=>'Categories manager', 'url'=>Yii::app()->createUrl('/news/categories/admin'), 'icon'=>'list-alt blue', "visible"=>Yii::app()->user->checkAccess("News@CategoriesAdmin", Yii::app()->user->Id)),
		array('label'=>'Pages manager', 'url'=>Yii::app()->createUrl('/news/pages/admin'), 'icon'=>'list-alt blue', "visible"=>Yii::app()->user->checkAccess("News@PagesAdmin", Yii::app()->user->Id)),
		'---',
		array('label'=>'Files manager', 'url'=>Yii::app()->createUrl('/files/files/admin'), 'icon'=>'list-alt blue', "visible"=>Yii::app()->user->checkAccess("Files@FilesAdmin", Yii::app()->user->Id)),
	)
);
if(!$contentMenu['items'][0]['visible'] &&  !$contentMenu['items'][1]['visible'] && !$contentMenu['items'][3]['visible'] && !$contentMenu['items'][4]['visible'] && !$contentMenu['items'][6]['visible']){
	$contentMenu = array();
}
$this->widget('bootstrap.widgets.TbNavbar', array(
    'type'=>'', // null or 'inverse'
    'brand'=>'Project CMS',
    'brandUrl'=>array('/dashboard'),
    'collapse'=>true, // requires bootstrap-responsive.css
    'brandOptions'=>array("rel"=>"tooltip-bt", "title"=>"Project CMS"),
    'items'=>array(
    	!Yii::app()->user->isGuest?'<ul class="nav" style="margin:0"><li class="divider-vertical"></li></ul>':'',
        !Yii::app()->user->isGuest?'<form class="navbar-search pull-left" action=""><input style="width: 150px;" type="text" class="search-query span2" placeholder="Search"></form>':'',
		array(
		'class'=>'bootstrap.widgets.TbMenu',
		'items'=>array(
					array('label'=>'Apps', 'url'=>'#', 'items'=>array(
						$contentMenu,
						array('label'=>'Media', 'url'=>Yii::app()->createUrl('/media/manage'), 'icon'=>'folder-open blue', "visible"=>Yii::app()->user->checkAccess("media@ManageIndex", Yii::app()->user->Id)),
						array('label'=>'Polls', 'url'=>Yii::app()->createUrl('/polls/poll/admin'), 'icon'=>'tasks blue', "visible"=>Yii::app()->user->checkAccess("polls@PollAdmin", Yii::app()->user->Id)),
						array('label'=>'Banners Manager', 'url'=>'#', 'icon'=>'th-large blue', 'items'=>array(
									array('label'=>'Create Banner', 'url'=>Yii::app()->createUrl('/banners/banner/create'), 'icon'=>'plus blue'),
									array('label'=>'List Banners', 'url'=>Yii::app()->createUrl('/banners/banner/admin'), 'icon'=>'list-alt blue'),
									'---',
									array('label'=>'Create Customer', 'url'=>Yii::app()->createUrl('/banners/customers/create'), 'icon'=>'plus blue'),
									array('label'=>'Customers Manager', 'url'=>Yii::app()->createUrl('/banners/customers/admin'), 'icon'=>'list-alt blue'),
								),
								"visible"=>Yii::app()->user->checkAccess("banners@BannerAdmin", Yii::app()->user->Id)
						),
						array('label'=>'Gallery Manager', 'url'=>Yii::app()->createUrl('/gallery/galleryItems/admin'), 'icon'=>'camera blue', "visible"=>Yii::app()->user->checkAccess("gallery@GalleryItemsAdmin", Yii::app()->user->Id)),
						array('label'=>'Comments', 'url'=>Yii::app()->createUrl('/comment/manage/admin'), 'icon'=>'comment blue', "visible"=>Yii::app()->user->checkAccess("comment@ManageAdmin", Yii::app()->user->Id)),
						array('label'=>'Products', 'url'=>Yii::app()->createUrl('/shop/products/admin'), 'icon'=>'shopping-cart blue', "visible"=>Yii::app()->user->checkAccess("shop@ProductsAdmin", Yii::app()->user->Id)),
						'---',
						array('label'=>'Menu Manager', 'url'=>Yii::app()->createUrl('/menu/menus/admin'), 'icon'=>'align-justify blue', "visible"=>Yii::app()->user->checkAccess("menu@MenusAdmin", Yii::app()->user->Id)),
						array('label'=>'Widget Manager', 'url'=>Yii::app()->createUrl('/widget/manage/admin'), 'icon'=>'th blue', "visible"=>Yii::app()->user->checkAccess("widget@ManageAdmin", Yii::app()->user->Id)),
						array('label'=>'Translate Manager', 'url'=>Yii::app()->createUrl('/translate/manage/admin'), 'icon'=>'globe blue', "visible"=>Yii::app()->user->checkAccess("translate@ManageAdmin", Yii::app()->user->Id)),
						array('label'=>'Bill Manager', 'url'=>Yii::app()->createUrl('/bill/default'), 'icon'=>'gift blue'),
					),
					'visible'=>!Yii::app()->user->isGuest,
					),
					array('label'=>'Help', 'url'=>Yii::app()->createUrl('/dashboard'), 'visible'=>!Yii::app()->user->isGuest, 'items'=>array(
							array('label'=>Yii::t('main', 'System Requirements'), 'url'=>Yii::app()->createUrl('/infosys/main/index'), 'icon'=>'check blue'),
							array('label'=>Yii::t('main', 'Author Info'), 'url'=>Yii::app()->createUrl('/infosys/main/author'), 'icon'=>'info-sign blue'),
					)),
				
				),
		),
    	'<form style="display: none;" name="langbox" action="" method="POST"><input type="hidden" name="lang" id="lang" value=""></form>',
    	//!Yii::app()->user->isGuest?'<ul class="nav" style="margin:0;"><li class="divider-vertical"></li></ul>':'',
    	!Yii::app()->user->isGuest?'<ul class="nav" style="margin:0;float: right"><li class="divider-vertical"></li><li><a class="sign-out btn btn-small" target="_blank" href="'.SITE_URL.'">View Site</a></li></ul>':'',
		(!Yii::app()->user->isGuest)?'
    		<ul class="pull-right nav">
    		<li class="divider-vertical"></li>
    		<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">'.Yii::app()->user->name.' <span class="caret"></span></a>
			<ul style="width: auto" class="dropdown-menu">
    			<li>
    				<div style="white-space: nowrap;">
    				<table>
    					<tr>
    					<td><div class="u-avatar"><img src="'.$avatar.'" /></div></td>
    					<td>
    						<div class="u-fo"><span class="u-fname">'.Yii::app()->user->name.'</span><span class="u-mail">'.Yii::app()->user->email.'</span>
		    					<a style="padding:0" href="'.Yii::app()->createUrl('/user/profile/edit').'">'.Yii::t('main','View Profile').'</a>
		    					<div style="overflow: hidden">
		    					<a style="padding:0;float: left;clear: none" href="'.Yii::app()->createUrl('/sys/backendSystemSettings/update').'">'.Yii::t('main','Setting').'</a>
		    					<a class="bx-lg" style="float: right;clear: none" href="/backend/index.php?r=user/logout">Sign out</a>
		    					</div>
		    				</div>
    					</td>
    					</tr>
    				</table>
    				
    				</div>
    			</li>
    			<li class="divider"></li>
    			<li><a tabindex="-1" href="/backend/index.php?r=user/profile/changepassword"><i class="icon-random icon-blue"></i>'.Yii::t('main','Change Password').'</a></li>
    			'.$isSupperAdmin.'
    		</ul>
    		</li>
    	</ul>':'',
		array(
			'class'=>'bootstrap.widgets.TbMenu',
			'htmlOptions'=>array('class'=>'pull-right'),
			'items'=>array(
				$languageArray,
			),
		),
    ),
)); ?>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('a[rel="tooltip-bt"]').tooltip({'placement':'bottom'});
});
/*]]>*/
</script>
<div class="container" id="page">
	<div id="alert-msg">
	<?php if(Yii::app()->user->hasFlash('success')):?>
		<div class="alert alert-success"><i class="icons-notice-success"></i><a class="close" data-dismiss="alert">×</a><?php echo Yii::app()->user->getFlash('success');?></div>
	<?php elseif(Yii::app()->user->hasFlash('error')):?>
		<div class="alert alert-error"><i class="icons-notice-error"></i><a class="close" data-dismiss="alert">×</a><?php echo Yii::app()->user->getFlash('error');?></div>
	<?php elseif(Yii::app()->user->hasFlash('info')):?>
		<div class="alert alert-info"><i class="icons-notice-info"></i><a class="close" data-dismiss="alert">×</a><?php echo Yii::app()->user->getFlash('info');?></div>
	<?php endif;?>
	</div>
	
	<?php echo $content; ?>

	<div class="clear"></div>

</div><!-- page -->
<?php 
if(Yii::app()->user->isGuest){
	$f_class = "footer-fixed";
}else{
	$f_class = "footer";
}
?>
<div id="<?php echo $f_class;?>">
	<div id="wr-foot">
		Copyright &copy; <?php echo date('Y'); ?> by <a href="mailto:phuong.nguyen.itvn@gmail.com">phuong.nguyen.itvn@gmail.com</a>.<br/>
		All Rights Reserved.<br/>
		<?php echo Yii::powered(); ?>
	</div>
</div><!-- footer -->
</body>
</html>
